package com.yy.service.impl;

import com.yy.service.MyMessageProvider;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * Author young
 * Date 2022/12/30 21:41
 * Description: SpringCloudAlibaba
 */
@Service
public class MessageProviderImpl implements MyMessageProvider {
    @Resource
    private StreamBridge streamBridge;
    @Override
    public String message() {
        String s = UUID.randomUUID().toString();
        streamBridge.send("myChannel-out-0",MessageBuilder.withPayload(s).build());
        System.out.println("序列值为："+s);
        return null;
    }
}

